package com.bwie.controller;

import com.bwie.common.domain.User;
import com.bwie.common.domain.response.UserLoginRes;
import com.bwie.common.result.Result;
import com.bwie.service.UserServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @className: UserController
 * @Description: TODO
 * @version: v1.８.0
 * @author: 刘鑫
 * @date: 2025/8/24 11:25
 */
@CrossOrigin
@RestController
@RequestMapping("auth")
public class UserController {
    @Autowired
    private UserServcie userServcie;

    @PostMapping("login")
    public Result login(@RequestBody @Valid User user){
        UserLoginRes userLoginRes= userServcie.login(user);
        return Result.success(userLoginRes);
    }

    @GetMapping("sureRole/{roleId}")
    public String sureRole(@PathVariable("roleId") Integer roleId){
        String token=userServcie.sureRole(roleId);
        return token;
    }

    //获取用户积分
    @GetMapping("selectUserIntegral")
    public Result selectUserIntegral(){
        return Result.success(userServcie.selectUserIntegral());
    }
}
